﻿CREATE TRIGGER [tu_vVideos]
    ON [dbo].[vVideos]
    INSTEAD OF UPDATE 
    AS 
    BEGIN
    	SET NOCOUNT ON
    	
    	UPDATE	[dbo].[Video]
    	SET		SongID = i.SongID,
    			EventID = i.EventID,
    			VersionID = i.VersionID,
    			DateLastPlayed = i.DateLastPlayed,
    			DateProduced = i.DateProduced,
    			PlayCount = i.PlayCount,
    			SkipCount = i.SkipCount,
    			CalculatedRating = i.CalculatedRating,
    			UserRating = i.UserRating,
    			StartPosition = i.StartPosition,
    			Length = i.Length,
    			ThumbnailPosition = i.ThumbnailPosition,
    			ThumbnailFilePath = i.ThumbnailFilePath,
    			SyncToPMP = i.SyncToPMP
		FROM    inserted i INNER JOIN 
				[dbo].[Video] v ON i.VideoID = v.VideoID
		
		UPDATE	[dbo].[VideoFile]
		SET		FilePath = i.FilePath,
				OriginalFileName = i.OriginalFileName,
				CurrentFileName = i.CurrentFileName,
				DateAdded = i.DateAdded,
				VideoLength = i.VideoLength,
				AudioLength = i.AudioLength,
				FileSize = i.FileSize,
				VideoWidth = i.VideoWidth,
				VideoHeight = i.VideoHeight,
				AudioSubType = i.AudioSubType,
				VideoSubType = i.VideoSubType,
				AudioBitRate = i.AudioBitRate,
				VideoBitRate = i.VideoBitRate,
				FourCC = i.FourCC,
				FrameRate = i.FrameRate,
				FileType = i.FileType,
				IsVBR = i.IsVBR,
				IsDeleted = i.IsDeleted,
				IsPrivate = i.IsPrivate,
				IsReplacement = i.IsReplacement,
				MediaClassID = i.MediaClassID
		FROM	inserted i INNER JOIN
				[dbo].[VideoFile] vf ON i.VideoFileID = vf.VideoFileID
		
    END
